import threading

class ThreadWorker(threading.Thread):
    def __init__(self, target, args=()):
        super().__init__()
        self.target = target
        self.args = args

    def run(self):
        self.target(*self.args)

# 使用示例
def print_numbers():
    for i in range(8):
        print(i)

thread = ThreadWorker(target=print_numbers)
thread.start()
thread.join()